<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header">Danh sách tin từ các cửa hàng gửi tới</h3>
    </div>
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default"> 
            <div class="panel-body">               
                     <div class="table-reponsive">
                    <form name="add_question" id="add_question" action="<?php echo $this->url(array("action"=>"traloitbkh")) ?>">
                        <table name="list_question" id="list_question" class="table table-hover">
                            <tr class="success">
                                <th>Chọn</th> <th>Tên cửa hàng</th><th>Tiêu đề</th><th>Nội dung</th><th>Nội dung trả lời</th><th>Trạng thái</th>
                              </tr>
                              <?php 
                                 foreach($this->data as $item){                                   
                                     if($item->getAnswer()==""){
                                         $tinhtrang="Mới";
                                     }elseif ($item->getAnswer()!=""){
                                         $tinhtrang="Đã trả lời";
                                     } 
                                       if($item->getUser_Id()==0){
                                         $user="Tất cả";
                                     }  else { 
                                         $user=GlobalLib::getName("user", $item->getUser_Id(), "username");
                                     }
                                     //nếu không cho trả lời thì($item->getUser_Id()==0)||
                                     if(($item->getAnswer()!="")&&($item->getAdmin_Id()!=0)){
                                          $strtam="<td class=\"a\"id=\"abc".$item->getId()."\"></td>";
                                     }elseif(($item->getAnswer()=="")||($item->getAdmin_Id()==0)){ 
                                          $strtam="<td class=\"a\"id=\"abc".$item->getId()."\"><input type=\"checkbox\" name=\"select_question\"id=\"ck".$item->getId()."\"></td>";
                                     }
                                      if(substr($item->getTitle(),0,1)=="D"){ 
                                   echo " <tr>
                                       ".$strtam."
                                        <td class=\"t\">".$user."</td>
                                        <td class=\"t\">".substr($item->getTitle(),1)."</td>    
                                         <td class=\"u\">".$item->getQuestion()."</td>
                                        <td class=\"q\" >".$item->getAnswer()."</td>
                                        <td class=\"q\" >".$tinhtrang."</td>    
                                        </tr>";}
                                 }
                               ?>
                        </table>
                        <input type ="hidden" name="list_selectQuestion" id="list_selectQuestion" value="" ></br>                      
                                <?php 
                                   // echo $this->paginationControl($this->data, 'Sliding' , 'feedback/pagination.phtml'); 
                                    ?>
                            </div></br>
                        <div class="form-group"><center>
                               <button type="submit" class="btn btn-default"id="submit">Chọn</button>
                               <a class="" href="<?php echo $this->url(array("action"=>"listanswer")) ?>">   <button type="button" class="btn btn-default" id ="button">Trở Về</button></a></center>
                               </center>
                        </div>
                    </form>    
                </div>
               
            </div>
        </div>
    </div>
</div>    
<script type="text/javascript"> 
    <?php  foreach ($this->data as $item){ ?> 
     $("#ck"+"<?php echo $item->getId() ?>").click(function(){
          if( $("#ck"+"<?php echo $item->getId() ?>").is(':checked')){
             $("#list_selectQuestion").val($("#list_selectQuestion").val()+"<?php echo $item->getId()?>"+",");           
          }else{
              var t="<?php echo $item->getId()?>"+","; 
              var str = $("#list_selectQuestion").val();
                  str=str.replace(t,"");
              $("#list_selectQuestion").val(str);
          }
   });
    <?php }?>
</script>
